<?php
/**
 * Created by PhpStorm.
 * User: DRG
 * Date: 2018/5/27
 * Time: 21:39
 */

$http = new swoole_http_server("0.0.0.0",80);
//设置静态资源目录
$http->set([
    "enable_static_handler" => true,
    "document_root"         => '/home/demo/data'
]);
$http->on('request',function ($request,$response){

//    print_r($request->get);//接受get参数
    $response->cookie('duruigang','xxxxxx',time()+1800);//设置cookie
    $response->end("<h1>Hello Swoole. #".rand(1000, 9999)."</h1>");
});

//启动服务器
$http->start();